import React from 'react'
// ===================================================================== Temp
import SubmitForm from '#cpt/temp/SubmitForm'
// ===================================================================== global declare
const { $fn, $Lazy, $http } = window
// ===================================================================== Lazy
const Page 		= $Lazy.load(()=>import('#tp/page/page-container'))
const Box 		= $Lazy.load(()=>import('#tp/box/box'))
const Button 	= $Lazy.load(()=>import('@antd/button'))
const SaoImage 	= $Lazy.load(()=>import('#tp/sao'))
const ResetExp 	= $Lazy.load(()=>import('./cpt/reset-exp'))
// ===================================================================== data
const StatusData = [
	{ name:'未领取', 	value:'0' },
	{ name:'已领取', 	value:'1' },
]
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:{},
		pag: {},
		value:null,
		selectedKeys:[],
		// 搜索表单列表
		formData : [
			{ label: '',	disabled:false,	full:true, p:'请输入条码号', afterSuffix:()=>(
				<>
					<SaoImage />
					<Button label='查询' className='mlr15' disabled={ !this.state?.value || this.state.submitLoading } loading={this.state.pullLoading} onClick={this.onSearch} />
					<Button label='保存' disabled={ !$fn.hasObject(this.state.data) || this.state.pullLoading } onClick={()=> this.formRef.submit()}/>
				</>
			), onValue:({ value, formData })=>{
				this.setState({ value, formData })
			}, onEnter:()=> this.onSearch() },
			{ label: '条码号',		name: 'spec_code', 			full:true },
			{ label: '标本架编号',	name: 'sf_number', 			full:true },
			{ label: '实验号',		name: 'lb_tpl', 			full:true, disabled:false },
			{ label: '创建人',		name: 'founder', 			half:true },
			{ label: '领取人',		name: 'receive_user', 		half:true },
			{ label: '创建时间',		name: 'created_at',			half:true },
			{ label: '领取时间',		name: 'receive_time',	half:true },
			{ label: '岗位',			name: 'job_id', 			half:true },
			{ label: '状态',			name: 'handover_type', 		half:true, type:'select', data:StatusData },
		],
	}
	
	model = {}
	
	componentDidMount(){
		
	}
	
	// 查询
	onSearch = () => {
		$http.pull(this,'lis-lab-tag/getSpecInfo', { param:{ spec_code: this.state.value }, loading:true, onError:()=>{
			this.formRef.reset()
			this.setState({ data: {} })
		} }).then(data=>{
			this.formRef.setValue(data)
		})
	}

	render(){
		return (
			<Page nobc title='修改实验号'>
				<div className='fx ex'>
					<Box title='实验号修改' className='ex mt5 mr5' small scroll scrollClassName='p10' flex>
						{ 
							SubmitForm.call(this, { msg:'保存', labelWidth: 's6', disabled:true, api:'lis-lab-tag/modifyLabTag', 
								query: ({ spec_code, lb_tpl, sp_receive_time}) => ({ spec_code, new_lb_tpl:lb_tpl, receive_time:sp_receive_time})
							})
						}
					</Box>
					<ResetExp />
				</div>
			</Page>
		)
	}
}

export default Index